﻿using Microsoft.AspNetCore.Mvc;
using Nasty.Core.LoadParams;
using Nasty.Core.Registry;
using Nasty.QuartzModule.Areas.QuartzTask.Model;
using Nasty.QuartzModule.Areas.QuartzTask.Params;
using NetTaste;

namespace Nasty.QuartzModule.QuartzTask
{
	public interface IQuartzTaskService : IAutofacRegister
	{
		public QuartzTask GetQuartzTask(string id);

		public List<QuartzTask> GetQuartzTasks(GetQuartzTasksParams @params);

        public ResultData<QuartzTask> SaveQuartzTask(QuartzTaskModel model);

		public ResultData<string> DeleteQuartzTasks(List<string> ids);

        public PageData<QuartzTask> GetQuartzTaskPage(GetQuartzTaskPageParams @params);

		public ResultData<string> SetQuartzTaskEnabled(SetQuartzTaskEnabledParams @params);

		public PageData<QuartzTaskLog> GetQuartzTaskLogPage(GetQuartzTaskLogPageParams @params);
    }

	public class QuartzTaskService : IQuartzTaskService
	{
		public required IQuartzTaskRepository QuartzTaskRepository { get; set; }

		public ResultData<string> DeleteQuartzTasks(List<string> ids)
		{
			return QuartzTaskRepository.DeleteQuartzTasks(ids);
		}

		public QuartzTask GetQuartzTask(string id)
		{
			return QuartzTaskRepository.GetQuartzTask(id);
		}

     
        public PageData<QuartzTask> GetQuartzTaskPage(GetQuartzTaskPageParams @params)
        {
            return QuartzTaskRepository.GetQuartzTaskPage(@params);
        }

        public ResultData<QuartzTask> SaveQuartzTask(QuartzTaskModel model)
		{
			return QuartzTaskRepository.SaveQuartzTask(model);
		}

        public List<QuartzTask> GetQuartzTasks(GetQuartzTasksParams @params)
        {
            return QuartzTaskRepository.GetQuartzTasks(@params);
        }

        public ResultData<string> SetQuartzTaskEnabled(SetQuartzTaskEnabledParams @params)
        {
            return QuartzTaskRepository.SetQuartzTaskEnabled(@params);
        }

        public PageData<QuartzTaskLog> GetQuartzTaskLogPage(GetQuartzTaskLogPageParams @params)
        {
            return QuartzTaskRepository.GetQuartzTaskLogPage(@params);
        }
    }
}
